<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="common/include :: header('流程定义列表')" />

</head>
<body class="gray-bg">
<div class="container-div">
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <form id="formId">
                <div class="select-list">
                    <ul>
                        <li class="select-time">
                            <label>部署时间：</label>
                            <input type="text" class="time-input" id="startTime" placeholder="开始时间" name="beginTime"/>
                            <span>-</span>
                            <input type="text" class="time-input" id="endTime" placeholder="结束时间" name="endTime"/>
                        </li>
                        <li>
                            <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                            <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                        </li>
                    </ul>
                </div>
            </form>
        </div>

        <div class="btn-group-sm" id="toolbar" role="group">
            <a class="btn btn-success" onclick="deployMentlHandler()" shiro:hasPermission="business:serviceItem:add">
                <i class="fa fa-plus"></i> 流程文件部署
            </a>
        </div>
        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table"></table>
        </div>
    </div>
</div>
<th:block th:include="common/include :: footer" />
<th:block th:include="common/include :: jasny-bootstrap" />
</body>
<script th:inline="javascript">
    var prefix = ctx + "/business/bpmnInfo";
    $(function () {
        var options = {
            url: prefix + "/query",
            modalName:"流程定义",
            columns:[{checkbox:true},
                {
                    field:'id',
                    title: 'id',
                    visible: false
                },
                {
                    field:'deploymentId',
                    title:'部署id',
                    visible:false
                },{
                    field:'actProcessId',
                    title:'流程定义id',
                    sortable:true
                },{
                    field:'bpmnName',
                    title:'流程名称',
                    sortable:true

                },{
                    field:'info',
                    title:'描述信息',
                    sortable:true
                },{
                    field:'deployTime',
                    title:'部署时间',
                    sortable:true
                },{
                    field: 'resourceName',
                    title: '流程文件',
                    formatter:function(value, row, index) {
                        var url = prefix+"/readResource?deploymentId="+row.deploymentId+"&type=xml";
                        return '<a class="btn btn-info btn-xs " href="' + url + '" target="_blank"><i class="fa fa-search"></i></a> ';
                    }
                },
                {
                    field: 'diagramResourceName',
                    title: '流程图',
                    formatter:function(value, row, index) {
                        var url = prefix+"/readResource?deploymentId="+row.deploymentId+"&type=png";
                        return '<a class="btn btn-info btn-xs " href="' + url + '" target="_blank"><i class="fa fa-search"></i></a> ';
                    }
                },{
                    title:'操作',
                    formatter:function (value,row,index) {
                        var action = [];
                        action.push('<a class="btn btn-danger btn-xs " href="javascript:void(0)"' +
                            'onclick="deleteHandler('+row.id+')"><i class="fa fa-remove"></a>')
                        return action.join('')
                    }
                }
            ]
        };
        $.table.init(options);
    })


    function deployMentlHandler(){
        $.modal.open("流程部署", "/business/bpmnInfo/deployPage");
    }
    function deleteHandler(id){
        $.modal.confirm("确认删除选中流程定义么?", function() {
            $.operate.submit(prefix + "/remove?id="+id, "get");
        });
    }

</script>
</html>